<?php require_once('include/header1.php'); ?>
<?PHP
    require_once("admin_functions.php");
    require_once("classes/admin_users.php");
    chk_session();
?>
<?
    if($_POST['Submit_x'] != "") {
// Code to home page by purab  ad centre details.
        if($_FILES['top_banner']['name']) {
            if($_FILES['top_banner']['type'] == "image/pjpeg" OR $_FILES['top_banner']['type'] == "image/jpeg" OR $_FILES['top_banner']['type'] == "image/gif") {
                $banner_path="../uploaded/ads/";
                $ini_name = basename($_FILES['top_banner']['name']);
                $temp = explode(".",$ini_name);
                $len = count($temp);
                $new_file = "top_centre_banner.".$temp[$len-1];

                copy($_FILES['top_banner']['tmp_name'],$banner_path.$new_file) or die("Unable to upload top banner image");
                $sql = "update site_ads set image_name = '".$new_file."' where id= 1";
                mysql_query($sql);
            } else {
                $mesg .= "&nbsp;Provided top banner image file type not supported!<BR>";
            }
        }

        if($_POST['top_banner_reset'] == 'Y') {
            $sql_reset = ", image-clicks=0, image_views=0 ";
        }

        if($_POST['deactivate_top_banner'] == "Y") {
            $tmp_top_stat = "Y";
        } else {
            $tmp_top_stat = "N";
        }
        $sql = "update site_ads set url_for_image = '".addslashes($_POST['top_banner_url'])."', status = '".$tmp_top_stat."'".$sql_reset." where id=1";
        mysql_query($sql);

//	code ends here by purab - home page ad
// footer ad
        if($_FILES['footer_banner']['name']) {
            if($_FILES['footer_banner']['type'] == "image/pjpeg" OR $_FILES['footer_banner']['type'] == "image/jpeg" OR $_FILES['footer_banner']['type'] == "image/gif") {
                $banner_path="../uploaded/ads/";
                $ini_name = basename($_FILES['footer_banner']['name']);
                $temp = explode(".",$ini_name);
                $len = count($temp);
                $new_file = "footer_banner.".$temp[$len-1];

                copy($_FILES['footer_banner']['tmp_name'],$banner_path.$new_file) or die("Unable to upload footer banner image");
                $sql = "update site_ads set image_name = '".$new_file."' where id= 2";
                mysql_query($sql);
            } else {
                $mesg .= "&nbsp;Provided footer banner image file type not supported!<BR>";
            }
        }

        if($_POST['footer_banner_reset'] == 'Y') {
            $sql_reset = ", image-clicks=0, image_views=0 ";
        }

        if($_POST['deactivate_footer_banner'] == "Y") {
            $tmp_top_stat = "Y";
        } else {
            $tmp_top_stat = "N";
        }
        $sql = "update site_ads set url_for_image = '".addslashes($_POST['footer_url'])."', status = '".$tmp_top_stat."'".$sql_reset." where id=2";
        mysql_query($sql);
//footer ad end
// register ad
        if($_FILES['register_banner']['name']) {
            if($_FILES['register_banner']['type'] == "image/pjpeg" OR $_FILES['register_banner']['type'] == "image/jpeg" OR $_FILES['register_banner']['type'] == "image/gif") {
                $banner_path="../uploaded/ads/";
                $ini_name = basename($_FILES['register_banner']['name']);
                $temp = explode(".",$ini_name);
                $len = count($temp);
                $new_file = "register_banner.".$temp[$len-1];

                copy($_FILES['register_banner']['tmp_name'],$banner_path.$new_file) or die("Unable to upload register banner image");
                $sql = "update site_ads set image_name = '".$new_file."' where id= 3";
                mysql_query($sql);
            } else {
                $mesg .= "&nbsp;Provided register banner image file type not supported!<BR>";
            }
        }

        if($_POST['register_banner_reset'] == 'Y') {
            $sql_reset = ", image-clicks=0, image_views=0 ";
        }

        if($_POST['deactivate_register_banner'] == "Y") {
            $tmp_top_stat = "Y";
        } else {
            $tmp_top_stat = "N";
        }
        $sql = "update site_ads set url_for_image = '".addslashes($_POST['register_url'])."', status = '".$tmp_top_stat."'".$sql_reset." where id=3";
        mysql_query($sql);
        $mesg = "Ads information modified sussessfully.";
        header("location: eparinay_ads.php?flg=1");
//register ad end
            }
?>
<?php require_once('include/sidebar.php'); ?>
<div id="admin_full_inner_body">

    <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#33CCFF">
<? if($mesg) {?>
        <tr>
            <td height="10" class="mesg"><?=$mesg?></td>
        </tr>
    <? } else {

    }?>

        <FORM action="eparinay_ads.php" method="POST" enctype="multipart/form-data" name="comman_ads" id="comman_ads" onsubmit="javascript:return validateCityAd(this);">
            <tr>
                <td>
                    <!-- start top banner ad table -->
                    <table width="90%" border="0" align="center" cellpadding="5" cellspacing="0" class="main-table">
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr><?
                                    $sql = "select * from site_ads where id = 1 order by id ASC";
                                    $rs = mysql_query($sql) or die(mysql_error());
    $row=mysql_fetch_array($rs)
        ?>
                        <tr>
                            <td width="40%" class="login-text">Upload Top Banner : </td>
                            <td width="60%" class="admin-text1">
                                <input type="file" name="top_banner" maxlength="250" class="textbox" size="50"><BR>
						Current Top Banner<br>
					  (Ideal dimensions - width: 468px, height: 60px)

                                <img src="../uploaded/ads/<?=$row['image_name'] ?>" width="468" height="60" border="0" style="margin-top:2px"></td>
                        </tr>
                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Enter Link (URL) : </td>
                            <td><input  name="top_banner_url" type="text" class="textbox" id="top_banner_url"  value="<?=stripslashes($row['url_for_image'])?>" size="50" maxlength="255"></td>
                        </tr>

                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Deactivate this Ad :</td>
                            <td class="admin-text1"><input name="deactivate_top_banner" type="checkbox" value="Y" class="textbox" >
				    (click the checkbox to de-activate this ad)</td>
                        </tr>

                        <input name="deactivate_top_banner" type="hidden" value="Y">

                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Reset Clicks/Page Views for this Ad :</td>
                            <td class="admin-text1"><input name="top_banner_reset" type="checkbox" class="textbox" id="top_banner_reset" value="Y"> (click the checkbox to reset the clicks/page views to zero)</td>
                        </tr>
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr>
                    </table>
                    <!-- end top banner ad table -->		</td>
            </tr>
            <tr>
                <td height="10"></td>
            </tr>
            <tr>
                <td>
                    <!-- start top banner ad table -->
                    <table width="90%" border="0" align="center" cellpadding="5" cellspacing="0" class="main-table">
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr><?
    $sql = "select * from site_ads where id = 2 order by id ASC";
                                    $rs = mysql_query($sql) or die(mysql_error());
                                    $row=mysql_fetch_array($rs)
        ?>
                        <tr>
                            <td width="40%" class="login-text">Upload Footer Banner : </td>
                            <td width="60%" class="admin-text1">
                                <input name="footer_banner" type="file" class="textbox" id="footer_banner" size="50" maxlength="250">
                                <BR>
						Current Footer Banner<br>
						(Ideal dimensions - width: 728px, height: 90px)
                                <img src="../uploaded/ads/<?=$row['image_name']?>" width="400" height="49" border="0" style="margin-top:2px"></td>
                        </tr>
                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Enter Link (URL) : </td>
                            <td><input  name="footer_url" type="text" class="textbox" id="footer_url" value="<?=stripslashes($row['url_for_image'])?>" size="50" maxlength="255"></td>
                        </tr>

                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Deactivate this Ad :</td>
                            <td class="admin-text1"><input name="deactivate_footer_banner" type="checkbox" value="Y" class="textbox"> (click the checkbox to de-activate this ad)</td>
                        </tr>

                        <input name="deactivate_top_banner" type="hidden" value="Y">

                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Reset Clicks/Page Views for this Ad :</td>
                            <td class="admin-text1"><input name="reset_footer" type="checkbox" class="textbox" id="chk_reset_centre" value="Y">
					(click the checkbox to reset the clicks/page views to zero)</td>
                        </tr>
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr>
                    </table>
                    <!-- end top banner ad table -->		</td>
            </tr>
            <tr>
                <td height="10"></td>
            </tr>
            <tr>
                <td>
                    <!-- start right banner ad 1 table -->
                    <table width="90%" border="0" align="center" cellpadding="5" cellspacing="0" class="main-table">
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr><?
                                    $sql = "select * from site_ads where id = 3 order by id ASC";
                                    $rs = mysql_query($sql) or die(mysql_error());
    $row=mysql_fetch_array($rs)
        ?>
                        <tr>
                            <td width="40%" class="login-text">Upload Registeration Advert : </td>
                            <td width="60%" class="admin-text1">
                                <input name="register_banner" type="file" class="textbox" id="register_banner" size="50" maxlength="250"><BR>
						Current Registeration Advert<br>
						(Ideal dimensions - width: 210px, height: 450px)

                                <img src="../uploaded/ads/<?=$row['image_name']?>" width="89" height="200" border="0" style="margin-top:2px"></td>
                        </tr>
                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Enter Link (URL) : </td>
                            <td><input  name="register_url" type="text" class="textbox" id="register_url"  value="<?=stripslashes($row['url_for_image'])?>" size="50" maxlength="255"></td>
                        </tr>

                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Deactivate this Ad :</td>
                            <td class="admin-text1"><input name="deactivate_register_banner" type="checkbox" value="Y" class="textbox" > (click the checkbox to de-activate this ad)</td>
                        </tr>

                        <input name="deactivate_right_banner_1" type="hidden" value="Y">

                        <tr>
                            <td colspan="2" height="5"></td>
                        </tr>
                        <tr>
                            <td class="login-text">Reset Clicks/Page Views for this Ad :</td>
                            <td class="admin-text1"><input name="reset_register" type="checkbox" value="Y" class="textbox"> (click the checkbox to reset the clicks/page views to zero)</td>
                        </tr>
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr>
                    </table>
                    <!-- end right banner ad 1 table -->		</td>
            </tr>
            <tr>
                <td height="10"></td>
            </tr>
            <tr>
                <td align="center">

                    <input type="image" name="Submit" value="Y" src="images/submit.gif" border="0">		</td>
            </tr>
        </form>
    </table>
</div>

</div>

<?php require_once('include/footer1.php'); ?>
